
	var Ajax = function(){
		
			var xhr=null;
			var response = "";
		var sendWithPost = function(uri,data){
				
				if (window.XMLHttpRequest) { 
					xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject) 
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on appelle le fichier reponse.txt
				xhr.open("POST", uri, false);
				xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");         
				xhr.send(data);
				
			   response = xhr.responseText;
		}
		
		var sendWithGet = function(uri,data){
			
				if (window.XMLHttpRequest) { 
					xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject) 
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on appelle le fichier reponse.txt
				xhr.open("GET", uri+"?"+data, false);
				xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");         
				xhr.send(null);
				
			   response = xhr.responseText;
		}
		
		this.send = function(uri,data,method){
			if(typeof(method) == "undefined") method = "get";
			if(method=="post") sendWithPost(uri,data); else sendWithGet(uri,data);	
		}
		
		this.getResponse = function() {
			return response;	
		}
		
		
		this.ParseData = function(datas){
			var output = "";
				for(var data in datas){
					if(output!="")
						output += "&";
					
					output += data + "=" + datas[data];	
				}
			
			return output;
		}
	}
	
	//var ajax = new Ajax();
	//ajax.send("./javasscripts/preview.php",ajax.ParseData({"pagename":"test","code":"Un message"}),"post");
	
	
